const app = getApp()
const api = app.globalData.api
Page({
  data: {
    Height: 0,
    scale: 18,
    latitude: "",
    longitude: "",
    markers: [],
    circles: []
  },
  onLoad: function() {
    var _this = this;

    wx.getSystemInfo({
      success: function(res) {
        // 设置map高度， 根据当前设备宽高满屏显示 
        _this.setData({
          view: {
            Height: res.windowHeight
          }
        })
      }
    })

    console.log(wx.getStorageSync("city"))
    if (wx.getStorageSync("city").includes("长沙")) {
      wx.getLocation({
        type: 'wgs84',
        // 默认为 wgs84 返回 gps 坐标， gcj02 返回可用于 wx.openLocation 的坐标 
        success: function(res) {
          console.log(res)
          var j = res.longitude
          var w = res.latitude
          // console.log(j)
          _this.setData({
            latitude: 28.3226800000,
            longitude: 112.8429300000,
            markers: [{
              id: "1",
              latitude: 28.3226800000,
              longitude: 112.8429300000,
              width: 30,
              height: 30,
              iconPath: "image/address.png",
              title: "晟通长沙望城物流园"
            }],

          })
        }
      })
    } else {
      wx.getLocation({
        type: 'wgs84',
        // 默认为 wgs84 返回 gps 坐标， gcj02 返回可用于 wx.openLocation 的坐标 
        success: function(res) {
          console.log(res)
          var j = res.longitude
          var w = res.latitude
          // console.log(j)
          _this.setData({
            latitude: 28.924549,
            longitude: 111.697281,
            markers: [{
              id: "1",
              latitude: 28.924549,
              longitude: 111.697281,
              width: 30,
              height: 30,
              iconPath: "image/address.png",
              title: "晟通集团常德产业园"
            }],

          })
        }
      })
    }
  },
  regionchange(e) {
    console.log("regionchange===" + e.type)
  },
  // 点击merkers 
  markertap(e) {
    console.log(e.markerId)
    // wx.showActionSheet({
    //   itemList: ["A"],
    //   success: function(res) {
    //     console.log(res.tapIndex)
    //   },
    //   fail: function(res) {
    //     console.log(res.errMsg)
    //   }
    // })
  },

})